mathy | using computer algebra systems to solve math problems | Math library
kandi X-RAY | mathy Summary
kandi X-RAY | mathy Summary
Tools for using computer algebra systems to solve math problems step-by-step with reinforcement learning
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of mathy
mathy Key Features
mathy Examples and Code Snippets
Community Discussions
Trending Discussions on mathy
QUESTION
I know there are similar questions about passing functions into functions, but I'm not clear on the effective solution for my particular problem.
The following function works but the formula is static. It only works on a fixed function, namely (in mathy pseudocode) f(a) = 3^a mod 17 = b
where f(11) = 7
ANSWER
Answered 2021-Feb-01 at 17:22Use *args
to pass additional arbitrary number of arguments to the function.
QUESTION
Pointer assignment of index is being consistently inconsistent within addData(..)
. I expect memory address is moving around as underlying array increases in size.
Behavior: I assign to variable A
, then assign B = A*0.2
, then assign y = sig(B)
, finally B = y
. Sometimes on the next loop B == y
|| B == A*0.2
. It is perfectly consistent across multiple executions.
I made a simpler and more full version of the code.
...ANSWER
Answered 2020-Nov-29 at 04:22The problem is with the pointer assignments as you build the slice you are trying to reference. The addresses keep changing.
QUESTION
I've been told many times that floating point arithmetic has the greatest precision if the numbers operated on are close to 1.0
(or sometimes 0.1
). Is there any truth to this?
With "arithmetic" I mean things like a + b
, a * b
, a / b
, but also sqrt(x)
and other mathy functions.
To be specific, let's say that all variables are IEEE 64 bit double precision floating point numbers.
ExampleIn physics simulation code, physical units are usually incorporated by mapping them to floating point values. Here we have a lot of freedom, but one choice is to go with the SI/metric system, something like
...ANSWER
Answered 2020-Oct-10 at 00:03Is floating point math more precise for values close to unity?
Not really.
In general, floating point math well preserves realtive precision for *
, /
, sqrt()
cover the lion’s share of the floating point range. +
, -
are subject to significant loss of relative precision (to the result) due to subtraction of nearby values.
Overall, there is little difference for normal numbers for relative precision. It varies from (0.5 to 1.0] * 2-53.
The absolute precision changes in steps for powers of 2.
Floating point numbers [0.5...1.0) have the same absolute precision. For double
2-54.
Floating point numbers [1.0...2.0) have the same absolute precision. For double
2-53.
Floating point numbers [2.0...4.0) have the same absolute precision. For double
2-52.
Floating point numbers [4.0...8.0) have the same absolute precision. For double
2-51.
etc.
floating point arithmetic has the greatest precision if the numbers operated on are close to 1.0 (or sometimes 0.1). Is there any truth to this?
Values just under a power-of-2 have a higher absolute precision (by about 2x) than values just above a power of 2.
With tiny subnormal values, precision is lost, a bit per power of 2 until 0.0 is reached.
Advanced: Trig functions has a special concern when their magnitude is large. A high quality sin(1e10)
does an internal extended high precision argument reduction to the primary [-pi ... pi] range. Not all trig function implementations handle this step well. So for radians arguments, starting in the primary range is useful to maintain precision. For degree arguments, a simple fmod(deg, 360.0)
is a simple and precise range reduction.
QUESTION
Hi guys I'm having some issues to get data from this page from app store: app store reviewshttps://apps.apple.com/us/app/mathy-cool-math-learner-games/id1476596747#see-all/reviews
I want to retrieve at first a string showing the ratings that a user give for the app. And they are inside of a figure tag with class = "we-star-rating ember-view we-customer-review__rating we-star-rating--large" and is the name of attribute @aria-label.
Here is my code:
...ANSWER
Answered 2020-Aug-09 at 02:18The top three reviews are loaded as part of the HTML but the rest are loaded by javascript. Which is why you're only getting the first three results.
I'm not entirely sure whether this is the whole code you have for using scrapy. I'd be interested in why you choose that part of scrapy.
So deaing with javascript is a huge part of web scraping modern websites. I'm not entirely sure whether you're primarily using scrapy to webscrape. There are a few options to handle javascript with scrapy though.
Information on dynamic Web ScrapingFirst knowing that websites these days grab information on the fly, using javascript to invoke HTTP requests, called an AJAX request (Asynchronous Javascript and XHTML). This makes either a post or get HTTP request to an API/server and that HTTP response gives back information. In this case, they have preloaded 3 results into the HTML but asked for the rest of the reviews on loading the page with javascript.
In general there are two ways to deal with javascript orientated websites.
- Re-engineer the HTTP requests - This is the most efficient way to get the data you want. You want to mimic these HTTP requests that javascript is invoking. If you can do that and this sometimes requires you to post headers, parameters and cookies then you can get the data you want.
- Using some form of browser automation. Selenium is the package of choice, although never meant to be used in this way originally. It's slow, inefficient and brittle if using larger datasets.
For your particular website, you can re-engineer the HTTP requests to get the information you want. This is the ideal situation.
But how did I know that? Well one of the things you can do in chrome is turn off javascript. You have to inspect the page and go to the settings (click the three dots on the very right hand side of the page -> more tools -> settings). Refresh the page without javascript. You'll see there is only three reviews to see.
To understand what's happening using the ChromeDev Tools is very informative. If you go to the network tab when you right-click and inspect the page you'll see all the requests and responses made of the server. Going to the XHR tab is where you will find requests made that has the data you want. Here you have a bunch of requests and the responses.
See the pic below, I've inspected the page, gone to network and refreshed the page. This records the activity of the browser's requests and responses.
You can see there are about 6 requests, 5 GET requests and one POST requests. If you click each request you'll see a pop up box on the right hand side with the request data, preview and response.
Here I've clicked the first request, I've clicked preview, and you can see if you click through that there's some reviews.
I can see in the HTTP request for that data there's an offset of 10, which means it's grabbing the next 10 requests.
So I'm going to alter that offset to see if I can get the first 10 and then the second 10 (There's 20 reviews on this page).
Without having to manually input the parameters and headers etc... You can copy the request into a CURL. This can then be converted using a site like curl.trillworks.com
into a nice python format.
Now it's worth while looking at the preview data, because you're going to have to use requests to process this. You're going to end up with a JSON object, you can tell this from the accept part of the HTTP get request is application/json
.
So having copied this request into curl.trillworks.com. We have the below.
Coding ExampleQUESTION
The problem is, given a number of blocks, how many ways are there to build stairs using that finite amount of blocks where there is always any incline between any two neighboring steps.
This means that a two step staircase from 100 to 1 step is valid. Of course, more blocks mean you can have more steps.
I wrote a function that accomplishes this, albeit very slowly when it gets to larger number of blocks, and I'm not sure how I can improve its runtime.
If you want a quick breakdown of my logic, it works out logically that by recursively expanding the highest step into all possible permutations of two steps (that would still put the second step above the former second step), eventually you get all possible step permutations.
Maybe there's a more mathy way of doing this, but I approached it from a programming pov. Welcome to hear any different suggestions though, if my approach is just too slow!
...ANSWER
Answered 2020-Jul-05 at 19:17Here is an alternative recursive/backtracking approach:
QUESTION
Context:
I started teaching myself a few new libraries using Jupyter Lab. I know showing emotion on SO is strictly forbidden and this will get edited, but WOW, Jupyter notebooks are cool!
Anyway, I'm taking notes in markdown as I work through code examples. It gave me the idea of writing my own little textbook as I learn.
For example, in notebook 1, I talk about (teach myself) linear regression. It take notes on vocabulary, show some mathy formulas then work through some code examples. End section.
In notebook 2, I start the conversation about different metrics to show how effective the regression model was. Then I want to execute some code to calculate those metrics... but all the code for the regression model is in the last notebook and I can't access it.
Question:
Is there a way to link these two notebooks together so that I don't have to re-write the code from the first one?
My attempt:
It seems like the closest thing to what I want to do is to use
%run notebook_01.ipynb
However, this throws an error. Note that it appears to search for a .py file to run:
ERROR:root:File 'linear_regression01.ipynb.py' not found.
I have found some questions/answers where this appears to work for other users, but it is not for me.
Edit: I got the magic command %run
to work, however it runs AND prints the entire first notebook into the second. I'ts good to know how to do this and it does achieve the goal of not having to re-code, but it re-prints absolutely everything, which I do not want.
ANSWER
Answered 2020-Mar-12 at 22:49Ok, I found the answer by way of suppressing outputs:
Just put this at the top of your second notebook:
QUESTION
I've observed errors when rendering math in matplotlib 2.0.2, when using the default mathtext as opposed to the LaTeX math rendering engine. It seems that some glyphs (in my case the minus and the multiplication sign) is not recognized by mathtext. What makes it really weird is that the error only occurs when these particular glyphs appear in tick labels. When I deliberately type some mathy expression into e.g. the figure title, it works fine.
Consider the below example and the resultant image:
...ANSWER
Answered 2017-Nov-14 at 22:49I find the STIX fonts to be acceptable substitutes for computer modern.
QUESTION
I'm trying to come up with a function/mapping from a given number n
, to two numbers lo
and hi
. Both lo
and hi
are of some multiple of 2, starting from the value 6.25. Both lo
and hi
also have the property that lo <= n < hi
.
Essentially lo
and hi
are the two nearest values to n
, formed from 6.25 * (2^x)
where x
is unknown.
It can be assumed that n >= 6.25
.
Some examples are:
...ANSWER
Answered 2020-Jan-17 at 05:11This should do the trick:
QUESTION
Getting more errors again this time, except this time it's on the webgl side instead of the mathy algorithm side.
My previous post was just about drawing a simple 2d recursive tree. The thing I'm trying to do now is to draw a tree at the location of the mouseclick, and with red lines if left click, blue if right. I fixed my previous problem and was able to get the tree to show up in my previous build of the program. However, now a tree doesn't even show up when I click on the canvas. When I console log the array where the points are stored however, all the points seem to be there. I think I'm missing something, but I don't know webgl enough to know what that may be.
I have made a working program that can draw different colored points depending on mouse click, at the mouse position, but I'm still not experienced enough to figure out what I have in that program that is allowing it to work and why this current program isn't able to display anything.
my current program:
...ANSWER
Answered 2019-Oct-13 at 14:03The code you posted only calls gl.drawXXX
one time in main so it's never going to draw anything ever again.
You have things set up so when the mouse is pressed click
will be called but click
never calls gl.drawXXX
Further, every time click
is called you make a new buffer with a new set of points. That is not the normal way to use WebGL. The normal way is to setup your points once (once per thing you want to draw) and then use matrices to change position, orientation, scale.
I suggest you read some other tutorials on WebGL. This one kind of does what you're doing now but it follows up with how to change position, orientation, and scale, followed by how to do it with matrices for more flexibility. It also covers drawing multiple things
In any case to fix your code as is you need to draw after changing the vertices
QUESTION
I do have a problem with the out of this code this is the models used
...ANSWER
Answered 2019-Sep-23 at 22:30you must be instead of primary_navigation
use ->PrimaryNavigation
(as defined in your relationship)
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install mathy
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page